package com.shitou.shitouwarehouse.interceptor;

import com.shitou.shitoucommons.interceptor.LoginInterceptor;
import com.shitou.shitoucommons.opfeign.MemberFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * class detail:
 *
 * @author 石头人
 */
@Component
@SuppressWarnings("all")
public class WareCheckLogin extends LoginInterceptor implements HandlerInterceptor {

    @Autowired
    private MemberFeign memberFeign;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if ( handler instanceof HandlerMethod ){
            boolean isLogin = super.checkLogin(handler, request, response, memberFeign);

            boolean authority = super.checkAuthority(handler, request, response, memberFeign);

            return isLogin;
        }
        return true;
    }
}
